<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/financeReport.do?action=inventoryInfo" />

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD>
<script>
	var dateElement = "";
    function openCalendar(dateValue)
    {
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
    }
	function assignDate(passedValue)
    {   
	dateElement.value=passedValue;
	window.focus();
    }

// Added by Vasanth 06/09/2003
// disable the list to select the process-step from the list when finished goods option is choosen

function Disab() {
	
	len=document.wipInventoryInfo.reportType.length
	for(var i=0; i<len; i++){
		if(	document.wipInventoryInfo.reportType[i].checked){
			var temp = 	document.wipInventoryInfo.reportType[i].value;
				if(temp == 'finished' || temp == 'discrepancy' || temp == 'intransit'){
					document.wipInventoryInfo.process.disabled = true;
				}
		}
	}
}


// Added by Vasanth 06/09/2003
function Enable() {
	len=document.wipInventoryInfo.reportType.length
	for(var i=0; i<len; i++){
		if(	document.wipInventoryInfo.reportType[i].checked){
			var temp = 	document.wipInventoryInfo.reportType[i].value;
				if(temp == 'wip' || temp == 'inventory'){
					document.wipInventoryInfo.process.disabled = false;
				}
		}
	}

}

/*
* Added by Vasanth 08/08/2003
* Date validation 
*/

function getYear(d) { 
  return (d < 1000) ? d + 1900 : d;
  }

function isDate (year, month, day) {

  month = month - 1;  
  var tempDate = new Date(year,month,day);
  if ( (getYear(tempDate.getYear()) == year) &&
     (month == tempDate.getMonth()) &&
     (day == tempDate.getDate()) )
      return true;
  else
     return false
  }


/*
* Vasanth 08/5/2003...
* There was a problem with the CR, if the date entered was of the format (m/d/yyyy) the prompt sent was not recognised by
* CR tool thus I had to append 0 infront of the month before it was sent to the Proc in the CR.
* This function takes care of the aforesaid problem.
*/
function dateCheck(){
	//var d = new Date();
	var date_check = document.wipInventoryInfo.asOfDate.value;
	var pa = document.getElementById("errors");
	//alert('1'+date_check);
		if (date_check=='')
			date_check='0';
		else{
			var month, date, year;
			var m;
			var day_check  = date_check.split('/');
			month=day_check[0];
			date=day_check[1];
			year=day_check[2];
			if (month<10) {
				if (month.length == 1) 
					month = "0"+month;
			}
			
			if (date<10){
				if (date.length == 1) 
					date = "0"+date;
			}
			//alert (date);
			//alert(month);
			date_check = month+"/"+date+"/"+year;
									
		}
		var check = date_check.split('/');
		if (check[0]== '00')
			date_check = '0';
		if (date_check!='0'){
			if (!isDate(year, month, date)){
				pa.innerHTML="Please enter a valid Date...!";
				date_check = 'InValid';
			}
		}

		return date_check;
}

function dateRange(){

var period="";
var cat="";
var d = new Date();
		var day = d.getDate();
		var month = d.getMonth()+1;
		var year = d.getFullYear();
		var hour = d.getHours();
		var min = d.getMinutes();
		var sec = d.getSeconds();
		if (month < 10)
			month = "0"+month;
		if (day<10)
			day = "0"+day;
		var today = month+"/"+day+"/"+year;
		var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;
		if (dateCheck()=='InValid')
			return;
		else {
			var datePrompt = dateCheck();
		}
		//alert('3'+datePrompt);
		
for (counter = 0; counter < wipInventoryInfo.reportType.length; counter++)
{
if (wipInventoryInfo.reportType[counter].checked){
	cat = wipInventoryInfo.reportType[counter].value;
	}
}

if ( cat=="inventory" )
{

	document.wipInventoryInfo.prompt0.value=document.wipInventoryInfo.productName.value;
	document.wipInventoryInfo.prompt1.value=document.wipInventoryInfo.process.value;
	document.wipInventoryInfo.prompt2.value='0';
	document.wipInventoryInfo.prompt3.value=document.wipInventoryInfo.asOfDate.value;
	document.wipInventoryInfo.prompt4.value= defaultPrompt;

	var process_type = document.wipInventoryInfo.prompt1.value;
	// Added if the date entered is today then call the default wip inventory report
	if(document.wipInventoryInfo.prompt3.value=='' || document.wipInventoryInfo.prompt3.value == today)
		document.wipInventoryInfo.prompt3.value='0';
	if(datePrompt!='0') 
		document.wipInventoryInfo.prompt3.value=datePrompt; 
	

		if(process_type=='SORT')
		document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Wip_Inventory.rpt";
		else if(process_type=='0')
		document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Cost/Inv_Cost_report.rpt";
		else if(process_type=='FAB')
	    document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Wip_Info_Fab.rpt"; 	
		else if(process_type=='FABLOT')
	    document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Wip_Info_Fab_Lot_History.rpt"; 	
		else if (process_type!='0' || process_type!='SORT' || process_type!='FAB' || process_type!='FABLOT')
		document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Wip_Info_Type.rpt";
		

		document.wipInventoryInfo.submit();
}

else if ( cat=="wip" )
{

	document.wipInventoryInfo.prompt0.value=document.wipInventoryInfo.productName.value;
	document.wipInventoryInfo.prompt1.value=document.wipInventoryInfo.process.value;
	document.wipInventoryInfo.prompt2.value='0';
	//document.wipInventoryInfo.prompt3.value=document.wipInventoryInfo.fromDate.value;
	//document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.toDate.value;
	document.wipInventoryInfo.prompt3.value=document.wipInventoryInfo.asOfDate.value;
	document.wipInventoryInfo.prompt4.value= defaultPrompt;
	
	var process_type = document.wipInventoryInfo.prompt1.value;
	
	if(document.wipInventoryInfo.prompt3.value==''|| document.wipInventoryInfo.prompt3.value == today)
		document.wipInventoryInfo.prompt3.value='0';
	if (datePrompt!='0')
		document.wipInventoryInfo.prompt3.value=datePrompt; 

		
	document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Cost/Wip_Cost_report_new.rpt";
	document.wipInventoryInfo.submit();
}

else if ( cat=="finished" )
{

	document.wipInventoryInfo.prompt0.value=document.wipInventoryInfo.productName.value;
	document.wipInventoryInfo.prompt1.value='0';
	document.wipInventoryInfo.prompt2.value='0';
	//document.wipInventoryInfo.prompt3.value=document.wipInventoryInfo.fromDate.value;
	//document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.toDate.value;
	document.wipInventoryInfo.prompt3.value=document.wipInventoryInfo.asOfDate.value;
	document.wipInventoryInfo.prompt4.value= defaultPrompt;
	//document.wipInventoryInfo.prompt3.value =date_check;
	
	if(document.wipInventoryInfo.prompt3.value=='' || document.wipInventoryInfo.prompt3.value == today)
		document.wipInventoryInfo.prompt3.value='0';
	if (datePrompt!='0') 
		document.wipInventoryInfo.prompt3.value=datePrompt; 
	
	document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Finished_Goods.rpt";
	document.wipInventoryInfo.submit();
}

}


</script>




<TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<form name="wipInventoryInfo" method="post" onSubmit="javascript:dateRange();">

<input type="hidden" name="prompt0">
<input type="hidden" name="prompt1">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt4">
<input type="hidden" name="prompt5">
<input type="hidden" name="prompt6">


<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/finance/finance_reports_menu.jsp" %>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<center><span class="NArialW">Wip / Inventory Cost Report</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>

  <table border="0" width="90%" align=right>
   <tr><td colsapn=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

   <tr><td colspan='4' align="left" class='NArialL'><b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font><b></td></tr>
      <tr><td colsapn=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
 	<tr>
      <td width="25%"><font class="NArialL">Product Name <br>(<bean:message key="label.mfgPartNumber"/>)</font></td>
      <td width="20%"><font class="NArialL">
      	<select size="1" name="productName" class="txfield">
	    <option value="0">All Products</option>
    <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
	<logic:notEqual name="mktgPartNumberSelectList" value="null">
 <option value = <bean:write name="mktgPartNumberSelectList" property="processStepId"/>>
 <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
 </option>
 </logic:notEqual>
 </logic:iterate>  </select>
 </td>
      <td width="8%">&nbsp;</td>
      <td width="13%"><font class="NArialL">Process</font></td>
	  <td width="20%"><font class="NArialL">
	   <select size="1" name="process" class="txfield">
			      <option value="0">Select Process Step </option>
		<option value="FAB">FAB</option>	
		<option value="SORT">SORT</option>
		<option value="ASSEMBLY">ASSEMBLY</option>
		<option value="TEST">TEST</option>
		<option value="Wafer Store">WAFER STORE</option>
		<option value="Die Bank">DIE BANK</option>
		<option value="Class Store">CLASS STORE</option>
		<option value="Mark and Pack">MARK&PACK</option>
		<option value="Finished Goods">FINISHED GOODS</option>
        </select></font></td>
	  <td width="12%">&nbsp;</td>
    </tr>


    <tr>

	  <td width="15%"><font class="NArialL">As of Date</font></td>
      <td width="20%"><font class="NArialL">
      	<input type="text" name="asOfDate" size="20" class="txfield"></font>&nbsp
		<a href="javascript:openCalendar(document.wipInventoryInfo.asOfDate)">
		<img src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20 border="0" onmouseover="window.status='Click to Select Date';return true" onmouseout="window.status='';return true"  ></a></td>
      <td width="8%">&nbsp;</td>
      <!--
	  <td width="15%"><font class="NArialL">From-Date</font></td>
      <td width="20%"><font class="NArialL">
      	<input type="text" name="fromDate" size="20" class="txfield"></font>&nbsp
		<a href="javascript:openCalendar(document.wipInventoryInfo.fromDate)">
		<img src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20 border="0"></a></td>
      <td width="8%">&nbsp;</td>
      <td width="13%"><font class="NArialL">To-Date</font></td>
      <td width="20%"><font class="NArialL">
      	<input type="text" name="toDate" size="20" class="txfield"></font>&nbsp;&nbsp;&nbsp;
      <a href="javascript:openCalendar(document.wipInventoryInfo.toDate)">
	  <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a></td>
       <td width="12%">&nbsp;</td>
	   -->

    </tr>
    <tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr><td colspan=6>
    	<input type="radio" name="reportType" checked value="inventory" onclick = "javascript: Enable()">
    	<font class="NArialL">Inventory</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="wip" onclick ="javascript: Enable()">
    	<font class="NArialL">Wip</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="finished" onclick = "javascript: Disab()" >
	<font class="NArialL">Finished Goods</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	
    </td></tr>
    <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
	<tr>
      <td colspan=6 align=center>
	  <a href="javascript:dateRange()">
	  <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Wip/Inventory Cost Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Wip/Inventory Cost Report" /></a>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <%-- <img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"> --%>
      <%--Modified by varma(29 jun 2004) --%>
        <a href="javascript:document.wipInventoryInfo.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
      </td>
    </tr>
  </table>


<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</form>
</BODY>
</HTML>
